package com.ftg.learn.chapter06;

/**
 * @author kangjx
 * @createTime 2022/7/13
 */
public class HomeWork {

    //直角边在右下角

    public void question4() {
        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 5; j++) {
                System.out.print(j <= 4 - i ? "*\t" : " \t");
            }
            System.out.println();
        }
    }


    public void question5() {
        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 9; j++) {
                System.out.print(j < 4 - i || j >= 5 + i ? " \t" : "*\t");
            }
            System.out.println();
        }
    }


    public void question6() {

        for (int i = 0, max = 8; i <= max; i++) {
            for (int j = 0; j <= max; j++) {
                int half = max >> 1;
                if (i < half && j < half - i) {
                    System.out.print(" \t");
                } else if (i < half && j > half + i) {
                    System.out.print(" \t");
                } else if (i > half && j < i - half) {
                    System.out.print(" \t");
                } else if (i > half && j > (max + half) - i) {
                    System.out.print(" \t");
                } else {
                    System.out.print("*\t");
                }
            }
            System.out.println();
        }
    }

    public void question7() {

        for (int i = 0, max = 8; i <= max; i++) {
            for (int j = 0; j <= max; j++) {
                int half = max >> 1;
                System.out.print((
                        (i < half && j < half - i)
                                || (i < half && j > half + i)
                                || (i > half && j < i - half)
                                || (i > half && j > (max + half) - i)
                ) ? " \t" : "*\t");
            }
            System.out.println();
        }
    }

    public void question8() {
        for (int i = 0, max = 8; i <= max; i++) {
            for (int j = 0; j <= max; j++) {
                System.out.print(i <= 1 || i >= max-1 || j  <= 1 ||j>= max-1?"*\t":" \t");
            }
            System.out.println();
        }
    }

}
